home *** CD-ROM | disk | FTP | other *** search
- /*
- * $RCSfile: shutserver.c,v $
- * $Revision: 1.1.1.1 $
- * $Date: 1996/05/04 21:55:33 $
- */
- /**********************************************************************
- * EXODUS Database Toolkit Software
- * Copyright (c) 1991 Computer Sciences Department, University of
- * Wisconsin -- Madison
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
- * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.
- * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
- * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * The EXODUS Project Group requests users of this software to return
- * any improvements or extensions that they make to:
- *
- * EXODUS Project Group
- * c/o David J. DeWitt and Michael J. Carey
- * Computer Sciences Department
- * University of Wisconsin -- Madison
- * Madison, WI 53706
- *
- * or exodus@cs.wisc.edu
- *
- * In addition, the EXODUS Project Group requests that users grant the
- * Computer Sciences Department rights to redistribute these changes.
- **********************************************************************/
-
-
- #include "sysdefs.h"
- #include "ess.h"
- #include "checking.h"
- #include "trace.h"
- #include "error.h"
- #include "list.h"
- #include "tid.h"
- #include "io.h"
- #include "lock.h"
- #include "object.h"
- #include "msgdefs.h"
- #include "adminmsg.h"
- #include "bf.h"
- #include "lsn.h"
- #include "loginfo.h"
- #include "load.h"
- #include "scan.h"
- #include "serverinfo.h"
- #include "sm_params.h"
- #include "btree.h"
- #include "msg_funcs.h"
- #include "sm_extfuncs.h"
- #include "sm_intfuncs.h"
- #include "sm_globals.h"
- #include "volume.h"
-
- #define max_volumes 100
-
- main (int argc, char** argv)
- {
-
- int option;
- VOLID vols[max_volumes];
- int volCount = 0;
- int i;
- int e;
- char *errorMsg;
-
- TRPRINT(TR_ADMIN, TR_LEVEL_1, ("shutting down server"));
-
- /*
- * Read the default configuration files to have the bufpages
- * option set.
- */
- e = sm_ReadConfigFile(NULL, argv[0], &errorMsg);
- if (e != esmNOERROR) {
- fprintf(stderr, "Configuration file error: %s\n", errorMsg);
- exit(0);
- }
-
- /*
- * Set any options from the command line
- */
- e = sm_ParseCommandLine(&argc, argv, &errorMsg);
- if (e != esmNOERROR) {
- fprintf(stderr, "command line error: %s\n", errorMsg);
- exit(0);
- }
-
- i = 32; /* us a minimal buffer pool */
- e = sm_SetClientOption("bufpages", &i, SM_int);
- if (e != esmNOERROR) {
- fprintf(stderr, "Could not set buffer pool option because: %s\n", sm_Error(sm_errno));
- exit(1);
- }
-
- /*
- * Initialize the storage manager.
- */
- e = sm_Initialize();
- if (e != esmNOERROR) {
- fprintf(stderr, "Could not initialize the storage manager because: %s\n", sm_Error(sm_errno));
- exit(1);
- }
-
- /*
- * Evaluate command line options
- */
- while (( option = getopt(argc, argv, "v:ah")) != EOF) {
- switch (option) {
- case '?':
- printf("Usage: %s [-a (for all known servers)] [-v volume_ID] [-h]\n", argv[0]);
- exit(1);
- break;
- case 'a':
- break;
- case 'v':
- vols[volCount] = atoi(optarg);
- volCount++;
- break;
- case 'h':
- printf("Usage: %s [-a (for all known servers)] [-v volume_ID] [-h]\n", argv[0]);
- printf(" [-a] shutdown servers managing all known volumes\n");
- printf(" [-v volume_ID] indicates that the server managing this volume\n");
- printf(" up to %d -v options may be given\n", max_volumes);
- exit(0);
- break;
- default:
- SM_ERROR(TYPE_FATAL, esmINTERNAL);
- }
-
- if (option == 'a') {
- volCount = -1;
- break;
- }
- if (volCount == max_volumes) {
- printf("too many -v options -- max is %d\n", max_volumes);
- exit(0);
- break;
- }
- }
-
- /*
- * Make sure there were no extra arguments
- */
- if (optind != argc || (volCount == 0) ) {
- printf("Usage: %s [-a (for all known servers)] [-v volume_ID] [-h]\n", argv[0]);
- exit(1);
- }
-
-
- if (volCount < 0) {
- printf("Shutting down all known servers\n");
- if (sm_ShutdownServer( VOL_ALL, (VOLID) 0,
- SHUT_ABORT_TRANS | SHUT_CLEAN_VOLUMES | SHUT_TAKE_CHECKPOINT) != esmNOERROR) {
- fprintf(stderr, "Shutting down all servers resulted in: %s\n", sm_Error(sm_errno));
- exit(1);
- }
- } else {
- for (i = 0; i < volCount; i++) {
- printf("Shutting down server for volume %d\n", (int) vols[i]);
- if (sm_ShutdownServer( VOL_BY_VOLID, vols[i],
- SHUT_ABORT_TRANS | SHUT_CLEAN_VOLUMES | SHUT_TAKE_CHECKPOINT) != esmNOERROR) {
- fprintf(stderr, "Shutting down the server managing volume %d resulted in: %s\n", (int) vols[i], sm_Error(sm_errno));
- }
- }
- }
- exit(0);
- }
-